package com.sy.controller.account;

import com.sy.bean.account.Account;
import com.sy.bean.account.HomeMoney;
import com.sy.common.bean.PageBean;
import com.sy.common.bean.ResultBean;
import com.sy.common.controller.BaseController;
import com.sy.service.account.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "账户管理")
@RequestMapping("/api")
public class AccountController extends BaseController {
    @Autowired
    AccountService accountService;
    @ApiOperation("账户列表")
    @PostMapping("/account/list")
    public ResultBean query(@RequestBody Map map) {
        List<Map> maps = accountService.queryList(map);
        return success("账户列表",maps);
    }
    @ApiOperation("保存账户")
    @PostMapping("/account")
    public ResultBean save(@RequestBody Account account){
        int rs = accountService.save(account);
        return gotoResult(rs,"保存");
    }

    @ApiOperation("修改账户")
    @PutMapping("/account")
    public ResultBean update(@RequestBody Account account){
        int rs=accountService.updateAcc(account);
        return gotoResult(rs,"修改");
    }

    @ApiOperation("删除账户")
    @DeleteMapping("/account")
    public ResultBean del(int id){
        int rs=accountService.delAcc(id);
        return gotoResult(rs,"删除");
    }
    @ApiOperation("首页资金")
    @GetMapping("eid")
    public ResultBean<HomeMoney> queryHomeMoney(int eid){
        HomeMoney homeMoney = accountService.queryHomeMoney(eid);
        return success("首页资金",homeMoney);
    }
}
